home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFGraph / Application Source / CDashboardApp.cp < prev    next >
Text File  |  1996-04-30  |  4KB  |  156 lines

  1. // ===========================================================================
  2. //    CDashboardApp.cp                ©1994 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    A "do nothing" Dashboard program that you can use as a starter for
  6. //    you own programs.
  7.  
  8. #include "CDashboardApp.h"
  9.  
  10. #include <LApplication.h>
  11. #include <LGrowZone.h>
  12. #include <LWindow.h>
  13. #include <UDrawingState.h>
  14. #include <UMemoryMgr.h>
  15. #include <URegistrar.h>
  16.  
  17. #include "CPlotPane.h"
  18.  
  19. #ifdef OOF_SmartHeap
  20.     #include "smrtheap.hpp"
  21. #endif
  22.  
  23. const ResIDT    WIND_Dashboard    = 200;
  24.  
  25.  
  26. // ===========================================================================
  27. //        • Main Program
  28. // ===========================================================================
  29.  
  30. void main()
  31. {
  32.                                     // Set Debugging options
  33.     SetDebugThrow_(debugAction_Alert);
  34.     SetDebugSignal_(debugAction_Alert);
  35.  
  36.     InitializeHeap(3);                // Initialize Memory Manager
  37.                                     // Parameter is number of Master Pointer
  38.                                     //   blocks to allocate
  39.     
  40.                                     // Initialize standard Toolbox managers
  41.     UQDGlobals::InitializeToolbox(&qd);
  42.     
  43.     new LGrowZone(20000);            // Install a GrowZone function to catch
  44.                                     //    low memory situations.
  45.                                     //    Parameter is size of reserve memory
  46.                                     //    block to allocated. The first time
  47.                                     //    the GrowZone function is called,
  48.                                     //    there will be at least this much
  49.                                     //    memory left (so you'll have enough
  50.                                     //    memory to alert the user or finish
  51.                                     //    what you are doing).
  52.     
  53.     CDashboardApp    theApp;            // Create instance of your Application
  54.     theApp.Run();                    //   class and run it
  55. }
  56.  
  57.  
  58. // ===========================================================================
  59. //        • CDashboardApp Class
  60. // ===========================================================================
  61.  
  62. // ---------------------------------------------------------------------------
  63. //        • CDashboardApp
  64. // ---------------------------------------------------------------------------
  65. //    Constructor
  66.  
  67. CDashboardApp::CDashboardApp()
  68. {
  69.     // Do the PPob Stuff         
  70.     URegistrar::RegisterClass(LWindow::class_ID,  (ClassCreatorFunc)LWindow::CreateWindowStream);
  71.     
  72.     URegistrar::RegisterClass(CPlotPane::class_ID,(ClassCreatorFunc)CPlotPane::CreatePlotPaneStream);
  73.  
  74.         // A Dashboard program has a single main Window that is
  75.         // displayed on start up. The "Visible on Creation" option
  76.         // for the Window (in its PPob resource) should be OFF,
  77.         // so that you can adjust the Window's contents before
  78.         // displaying it.
  79.         
  80.     mDisplayWindow = LWindow::CreateWindow(WIND_Dashboard, this);
  81.     
  82.         // +++ Add code here to configure Panes inside the Window
  83.         
  84.     mDisplayWindow->Show();
  85. }
  86.  
  87.  
  88. // ---------------------------------------------------------------------------
  89. //        • ~CDashboardApp
  90. // ---------------------------------------------------------------------------
  91. //    Destructor
  92.  
  93. CDashboardApp::~CDashboardApp()
  94. {
  95.         // +++ Add code here to cleanup (if necessary) before quitting
  96. }
  97.  
  98.  
  99. // ---------------------------------------------------------------------------
  100. //        • ObeyCommand
  101. // ---------------------------------------------------------------------------
  102. //    Respond to commands
  103.  
  104. Boolean
  105. CDashboardApp::ObeyCommand(
  106.     CommandT    inCommand,
  107.     void        *ioParam)
  108. {
  109.     Boolean    cmdHandled = true;
  110.     
  111.     switch (inCommand) {
  112.     
  113.         // +++ Add cases here for the commands you handle
  114.         //        Remember to add same cases to FindCommandStatus below
  115.         //        to enable/disable the menu items for the commands
  116.     
  117.         default:
  118.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  119.             break;
  120.     }
  121.     
  122.     return cmdHandled;
  123. }
  124.  
  125.  
  126. // ---------------------------------------------------------------------------
  127. //        • FindCommandStatus
  128. // ---------------------------------------------------------------------------
  129. //    Pass back status of a (menu) command
  130.  
  131. void
  132. CDashboardApp::FindCommandStatus(
  133.     CommandT    inCommand,
  134.     Boolean        &outEnabled,
  135.     Boolean        &outUsesMark,
  136.     Char16        &outMark,
  137.     Str255        outName)
  138. {
  139.     switch (inCommand) {
  140.     
  141.         // +++ Add cases here for the commands you handle.
  142.         //
  143.         //        Set outEnabled to TRUE for commands that can be executed at
  144.         //        this time.
  145.         //
  146.         //        If the associated menu items can have check marks, set
  147.         //        outUsesMark and outMark accordingly.
  148.         //
  149.         //        Set outName to change the name of the menu item
  150.     
  151.         default:
  152.             LApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  153.                                 outMark, outName);
  154.             break;
  155.     }
  156. }